<!-- selectImageFile.jsp -->
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>包图片旋转页面</title>
	</head>
	<body>
		<script type="text/javascript">
			var path="../json/getPackageImages.action";
			var imageArray = new Array();
			$.ajax({
				type:"POST",
				url:path,
				dataType:"json",
				async: false,
				timeout:SYSTEM.ajaxTimeOut,
				success:function(data){
					var displayImage = '';
					$.each(data.rows, function(index,item){
						var path="${pageContext.request.contextPath}/" + item.path;
						imageArray.push(item);
						displayImage +='<img src="'+ path +'" onClick="setImage(' + index +');" width="50" height="50" style="margin-left:40px;"/>';
						if(index != 0 && (index+1)%3 == 0){
							displayImage += '<br/><br/>';
						}
					});
					$("#imageList").append(displayImage);
				},
				error:function(){
					$.messager.alert('错误信息','获取包图片出错!','error');
				}
			});
			
			function setImage(index){
				$("#packagePicUrl").attr('value', imageArray[index].path.replace("/resources", "resources"));
				var selectPath = "${pageContext.request.contextPath}/" + $("#packagePicUrl").val();
				var s = '<img src="' + selectPath +'" width="50" height="50"/>';
				$("#imageDisplay").html(s);
				$('#imageSelect').window('close');
			}
			
			function picClear() {
				$("#packagePicUrl").attr('value','');
				$("#imageDisplay").html("");
				$('#imageSelect').window('close');
			}
		</script>
		<div style="margin:auto; width:96%;">
			<div id="imageList" style="margin-top:16px;margin-left:16px;"></div>
			<div>
				<input type="button" style="float:right;margin-bottom:0px;padding-bottom:0px" class="btn-gray" value="取消图片设置" onclick="javascript:picClear();"/>
			</div>
		</div>
		
	</body>
</html>
